package com.ruoyi.system.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.RxDoudianMsg;
import com.ruoyi.system.service.IRxDoudianMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 抖音回调消息Controller
 *
 * @author hjf
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/hmk/douDianCallBackMsg")
public class RxDoudianMsgController extends BaseController {
    @Autowired
    private IRxDoudianMsgService rxDoudianMsgService;

    /**
     * 查询抖音回调消息列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:douDianCallBackMsg:list')")
    @GetMapping("/list")
    public TableDataInfo list(RxDoudianMsg rxDoudianMsg) {
        startPage();
        List<RxDoudianMsg> list = rxDoudianMsgService.selectRxDoudianMsgList(rxDoudianMsg);
        return getDataTable(list);
    }

    /**
     * 导出抖音回调消息列表
     */
    @PreAuthorize("@ss.hasPermi('hmk:douDianCallBackMsg:export')")
    //@Log(title = "抖音回调消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RxDoudianMsg rxDoudianMsg) {
        List<RxDoudianMsg> list = rxDoudianMsgService.selectRxDoudianMsgList(rxDoudianMsg);
        ExcelUtil<RxDoudianMsg> util = new ExcelUtil<RxDoudianMsg>(RxDoudianMsg.class);
        util.exportExcel(response, list, "抖音回调消息数据");
    }

    /**
     * 获取抖音回调消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('hmk:douDianCallBackMsg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(rxDoudianMsgService.selectRxDoudianMsgById(id));
    }

    /**
     * 新增抖音回调消息
     */
    @PreAuthorize("@ss.hasPermi('hmk:douDianCallBackMsg:add')")
    //@Log(title = "抖音回调消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RxDoudianMsg rxDoudianMsg) {
        return toAjax(rxDoudianMsgService.insertRxDoudianMsg(rxDoudianMsg));
    }

    /**
     * 修改抖音回调消息
     */
    @PreAuthorize("@ss.hasPermi('hmk:douDianCallBackMsg:edit')")
    //@Log(title = "抖音回调消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RxDoudianMsg rxDoudianMsg) {
        return toAjax(rxDoudianMsgService.updateRxDoudianMsg(rxDoudianMsg));
    }

    /**
     * 删除抖音回调消息
     */
    @PreAuthorize("@ss.hasPermi('hmk:douDianCallBackMsg:remove')")
    //@Log(title = "抖音回调消息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(rxDoudianMsgService.deleteRxDoudianMsgByIds(ids));
    }
}
